#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# @Time: 2024-02-20 22:38

# @Despcription: 集合的定义及使用

if(1):
    # 集合只能使用set()函数来定义
    var_set     = set([1, 2, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6])
    var_set_1   = set([1, 2, 3, "a", "b", "c"])
    print(var_set)  # {1, 2, 3, 4, 5, 6}
    
    # 求并集
    print(var_set_1 | var_set)  # {1, 2, 3, 4, 5, 6}

    # 求交集
    print(var_set_1 & var_set)  # {1, 2, 3}

    # 求在A不在B的子集
    print(var_set_1 - var_set)  # {'b', 'c', 'a'}

    # 求在AB非交集的集合
    print(var_set_1 ^ var_set)  # {'c', 4, 5, 6, 'a', 'b'}
